#ifndef MODIFSC
#define MODIFSC

#include "projet.h"

void changecarbu(GtkWidget *emitter,t_modifs *modiff)
{
     int val = gtk_adjustment_get_value(GTK_ADJUSTMENT(emitter));
     char buff[64];
     sprintf(buff,"Carburant : %d L",val);
	 gtk_label_set_text(GTK_LABEL(modiff->entry[0]),buff);
	 modiff->av->carbu = val;
}
void changeconso(GtkWidget *emitter,t_modifs *modiff)
{
     int val = gtk_adjustment_get_value(GTK_ADJUSTMENT(emitter));
     char buff[64];
     sprintf(buff,"Consommation : %d %%",val);
	 gtk_label_set_text(GTK_LABEL(modiff->entry[1]),buff);
	 modiff->av->altconso = val;
}
void changevitesse(GtkWidget *emitter,t_modifs *modiff)
{
     int val = gtk_adjustment_get_value(GTK_ADJUSTMENT(emitter));
     char buff[64];
     sprintf(buff,"Vitesse : %d %%",val);
	 gtk_label_set_text(GTK_LABEL(modiff->entry[2]),buff);
	 modiff->av->altvitesse = val;
}

void modifs_avion(t_avion *av)
{
    GtkWidget *win,*table,*lbl[3],*scroll[3],*btquitt;
    GtkObject *scroller[3];
	char buff[64];
	t_modifs modiff;

	win = gtk_window_new(GTK_WINDOW_TOPLEVEL);
	gtk_window_set_position(GTK_WINDOW(win),GTK_WIN_POS_CENTER);
	gtk_window_resize (GTK_WINDOW(win),300,10);
	gtk_window_set_title(GTK_WINDOW(win),av->carac->nom);
	
	
	gtk_window_set_deletable(GTK_WINDOW(win),FALSE);
	
	table = gtk_table_new(3,4,FALSE);

	sprintf(buff,"Carburant : %d L",av->carbu);
	lbl[0] = gtk_label_new(buff);
	sprintf(buff,"Consommation : %d %%",av->altconso);
	lbl[1] = gtk_label_new(buff);
	sprintf(buff,"Vitesse : %d %%",av->altvitesse);
	lbl[2] = gtk_label_new(buff);

	btquitt = gtk_button_new_with_label("fermer");

	scroller[0] = gtk_adjustment_new(av->carbu,0,av->carac->carbumax,1,1,0);
	scroller[1] = gtk_adjustment_new(av->altconso,0,100,1,1,0);
	scroller[2] = gtk_adjustment_new(av->altvitesse,0,100,1,1,0);

	scroll[0] = gtk_hscrollbar_new(GTK_ADJUSTMENT(scroller[0]));
	scroll[1] = gtk_hscrollbar_new(GTK_ADJUSTMENT(scroller[1]));
	scroll[2] = gtk_hscrollbar_new(GTK_ADJUSTMENT(scroller[2]));

	gtk_table_attach_defaults(GTK_TABLE(table),lbl[0],1,2,0,1);
	gtk_table_attach_defaults(GTK_TABLE(table),lbl[1],1,2,1,2);
	gtk_table_attach_defaults(GTK_TABLE(table),lbl[2],1,2,2,3);
	gtk_table_attach_defaults(GTK_TABLE(table),scroll[0],3,4,0,1);
	gtk_table_attach_defaults(GTK_TABLE(table),scroll[1],3,4,1,2);
	gtk_table_attach_defaults(GTK_TABLE(table),scroll[2],3,4,2,3);
	gtk_table_attach_defaults(GTK_TABLE(table),btquitt,1,4,3,4);
	
	modiff.av = av;
	modiff.entry[0] = lbl[0];
	modiff.entry[1] = lbl[1];
	modiff.entry[2] = lbl[2];
	
	gtk_container_add(GTK_CONTAINER(win),table);

	gtk_signal_connect(GTK_OBJECT(scroller[0]),"value-changed",G_CALLBACK(changecarbu),&modiff);
	gtk_signal_connect(GTK_OBJECT(scroller[1]),"value-changed",G_CALLBACK(changeconso),&modiff);
	gtk_signal_connect(GTK_OBJECT(scroller[2]),"value-changed",G_CALLBACK(changevitesse),&modiff);
	gtk_signal_connect(GTK_OBJECT(btquitt),"clicked",G_CALLBACK(gtk_main_quit),NULL);

	gtk_widget_show_all(win);

	gtk_main();
	gtk_widget_destroy(win);
	mouse_b = 0;
}

#endif
